﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Xml.Linq;
using System.Linq;

namespace ArmoryBrowser.Entities.Achievements
{
    public class Category
    {
        #region Fields
        private CategoryData _categoryDataField;
        private Category[] _subcategoriesField;
        private String _nameField;
        private String _idField;
        #endregion
        #region Properties
        public CategoryData CategoryData
        {
            get
            {
                return this._categoryDataField;
            }
            set
            {
                this._categoryDataField = value;
            }
        }
        public Category[] Subcategories
        {
            get
            {
                return this._subcategoriesField;
            }
            set
            {
                this._subcategoriesField = value;
            }
        }
        public String Name
        {
            get
            {
                return this._nameField;
            }
            set
            {
                this._nameField = value;
            }
        }
        public String Id
        {
            get
            {
                return this._idField;
            }
            set
            {
                this._idField = value;
            }
        }
        #endregion
        #region Constructor
        public Category(XElement element)
        {
            Name = element.GetAttributeValue("name");
            Id = element.GetAttributeValue("id");
            CategoryData = element.Elements("c").Select(e => new CategoryData(e)).FirstOrDefault();
            Subcategories = element.Elements("category").Select(e => new Category(e)).ToArray();
        }
        #endregion
    }
}
